﻿Public Class ListeActivite
    Dim oLocalContext As DBMainContext


    Public Sub New(ByVal oType As PlanificationEvenement.TypeEvenement)

        ' Cet appel est requis par le concepteur.
        InitializeComponent()

        ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
        oLocalContext = New DBMainContext

        dgvActivite.DataSource = (From u In oLocalContext.PlanificationEvenement Where u.Type = oType Select u)


        For Each Col As DataGridViewColumn In dgvActivite.Columns
            If Not New List(Of String)(New String() {"Nom", "Description", "Traduction"}).Contains(Col.Name) Then
                Col.Visible = False
            End If
        Next

    End Sub

    Private Sub btnAjouter_Click(sender As System.Object, e As System.EventArgs) Handles btnAjouter.Click
        Dim oAjoutEven As New AjoutEvenement(PlanificationEvenement.TypeEvenement.Activite)

        MainForm.AddTabToTC("Nouvelle Activité", True, oAjoutEven)



    End Sub


    Private Sub dgvActivite_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvActivite.DoubleClick
        Dim oAjoutEven As New AjoutEvenement(CType(dgvActivite.SelectedRows(0).DataBoundItem, PlanificationEvenement))

        MainForm.AddTabToTC("Activité: " + CType(dgvActivite.SelectedRows(0).DataBoundItem, PlanificationEvenement).Nom, True, oAjoutEven)


    End Sub
End Class
